package org.dinnermate.gui;

import java.util.Date;

public class CalendarManagement
{
	public CalendarManagement(){
		
	}
	
	public static Date snapMinutes(Date date){
		int minutes = date.getMinutes();
		
		if(minutes < 8){
			minutes = 0;
		}
		else if(minutes <= 23){
			minutes = 15;
		}
		else if(minutes <= 38){
			minutes = 30;
		}
		else if(minutes <= 53){
			minutes = 45;
		}
		else{
			minutes = 0;
			date.setHours(date.getHours() + 1);
		}
		date.setMinutes(minutes);
		
		return date;
	}
	
	public static Date findEndTime(Date date, int duration){
		Date endDate = date;
		duration = duration * 60 * 1000;
		endDate.setTime(endDate.getTime() + duration);
		
		return endDate;
	}
}
